<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../assets/mock/mock-min.js"></script>
    <script>
        console.log(typeof (Mock.Random.date()));

        // 根据模板获取时间字符串
        console.log(Mock.Random.date());
        console.log(Mock.Random.time());
        console.log(Mock.Random.datetime());
        console.log(Mock.Random.date("yyyy年"))

        // 获取今天的相关时间信息-通过模板获取今天的相关信息
        console.log(Mock.Random.now());
        console.log(Mock.Random.now('year'));
        console.log(Mock.Random.now('month'));
        console.log(Mock.Random.now('week'));
        console.log(Mock.Random.now('day'));
        console.log(Mock.Random.now('hour'));
        console.log(Mock.Random.now('minute'));
        console.log(Mock.Random.now('second'));
        console.log(Mock.Random.now('yyyy年'));

        // 各种模板设置
        console.log(Mock.Random.datetime()); // 默认模板 yyyy-MM-dd HH:mm:ss
        console.log(Mock.Random.datetime("yyyy年MM月dd日 HH:mm:ss"));
        console.log(Mock.Random.datetime("yyyy年MM月dd日"));
        console.log(Mock.Random.datetime("HH:mm:ss"));
        console.log(Mock.Random.datetime("T"));

        // console.log(  new Date().getTime() )

        console.log(Mock.mock({
            day1: Mock.Random.datetime(),
            day2: Mock.Random.datetime("yyyy年MM月dd日 HH:mm:ss"),
            day3: "@datetime",
            day4: "@datetime(yyyy年MM月dd日)",
            day5: "@now(yyyy年MM月dd日)"
        }))

        // 生成图片 = 生成一个基于某个服务器的图片地址
        // Random.image( size, background, foreground, format, text )
        //      size 宽x高
        //      background 背景色
        //      foreground 图片前景色
        //      format 图片的后缀名
        //      text 图片的内容 

        // console.log( Mock.Random.image() )
        // console.log( Mock.Random.image("500x500") )
        let img1 = new Image()
        img1.src = Mock.Random.image();
        let img2 = new Image()
        img2.src = Mock.Random.image("500x500")
        let img3 = new Image()
        img3.src = Mock.Random.image("500x500", "#FF6600", "#FFFFFF", "png", "测试文本")

        window.onload = function () {
            document.body.appendChild(img1)
            document.body.appendChild(img2)
            document.body.appendChild(img3)

        }

        let imgs = Mock.mock({
            "imgs|10": [
                "https://api.ixiaowai.cn/mcapi/mcapi.php?_=@datetime(T)"
            ]
        }).imgs
        console.log(imgs)
        window.onload = function () {
            imgs.forEach(path => {
                let tempImg = new Image(300,300);
                tempImg.src = path;
                document.body.appendChild(tempImg);
            });
        }


    </script>
</head>

<body>

</body>

</html>